xquery version "0.9-ml"

(:returns a text string that represents a JavaScript data object :)
(:apostrophes are replaced with %u2019 because *sometimes* the encoding does not stick in the XML DB :)

xs:string('[')
,
let $node := xdmp:get-request-field("node")
(: let $node := "doc('wines.xml')/wines/wine/vintage" :)

for $value in xdmp:eval($node)
	return (xs:string("'"),fn:replace(xdmp:quote($value),"'","%u2019"),xs:string("',"))

,
xs:string(']')